package cn.itcast.rabbitmq.spring;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class Listener {

    @RabbitListener(bindings = @QueueBinding(
            // 指定当前方法接收的队列  durable？持久化
            value = @Queue(value = "spring.test.queue", durable = "true"),
            // 指定交换机
            exchange = @Exchange(
                    value = "spring.test.exchange",
                    // 如果存在当前名称的交换机，则直接使用
                    ignoreDeclarationExceptions = "true",
                    type = ExchangeTypes.TOPIC
                ),
            key = {"#.#"}
            )
    )
    public void listen(String msg){
        // 你好呀。我发生了修改，你来看看对不对！！
        System.out.println("接收到消息：" + msg);
    }
}
